<?php

// function __autoload($class_name) {
//     include 'class.' . strtolower($class_name) . '.php';
// }
require_once 'class.database.php';

class DetailKppnDao {

    public function createDetail(DetailKppn $detail) {
        $db = Database::getInstance();
        $con = $db->getConnection(1);

        $query = "INSERT INTO t_det_usulan_kppn(id_usulan_kppn,id_usulan_peg) ";
        $query.=" VALUES('$detail->id_usulan_kppn','$detail->id_usulan_peg')";
        //print_r($query);
        $result = $con->prepare($query);
        $result->execute();

        if ($result->rowCount() == 1) {
            return true;
        }

        return false;
    }

    public function getDetailById($id) {
        $db = Database::getInstance();
        $con = $db->getConnection(1);

        $query = "SELECT * FROM t_det_usulan_kppn WHERE id='$id'";

        $result = $con->prepare($query);
        $result->execute();

        if ($result->rowCount() == 1) {
            return $result->fetch();
        }

        return false;
    }


    public function getDetailByIdUsulan($id) {
        $db = Database::getInstance();
        $con = $db->getConnection(1);

        $query = "SELECT * FROM t_det_usulan_kppn WHERE id_usulan_kppn='$id'";

        $result = $con->prepare($query);
        $result->execute();

        if ($result->rowCount() >= 1) {
            return $result->fetchAll();
        }

        return false;
    }


}

class DetailKppn {

    var $id;
    var $id_usulan_kppn;
    var $id_usulan_peg;

}

?>